package com.ask.forMe.langchain4j.rag.loader;

import dev.langchain4j.data.document.Document;
import dev.langchain4j.data.document.loader.FileSystemDocumentLoader;
import dev.langchain4j.data.document.parser.apache.poi.ApachePoiDocumentParser;
import dev.langchain4j.data.document.parser.apache.tika.ApacheTikaDocumentParser;

public class MyDocumentLoader {
    /**
     * 使用 Apache Tika 解析文档1
     *
     * @param filePath
     * @return
     */
    public static Document loadAndParserByApacheTika(String filePath) {
        return FileSystemDocumentLoader.loadDocument(
                filePath,
                new ApacheTikaDocumentParser()
        );
    }

    /**
     * 使用Apache POI 解析文档
     * @param filePath
     * @return
     */
    public static Document loadAndParserByApachePoi(String filePath) {
        return FileSystemDocumentLoader.loadDocument(
                filePath,
                new ApachePoiDocumentParser()
        );
    }

    /**
     * 使用默认的文档解析器
     *
     * @param filePath
     * @return
     */
    public static Document loadAndParserByDefault(String filePath) {
        return FileSystemDocumentLoader.loadDocument(filePath);
    }
}
